package com.bawei.mall.user.contorller;

import com.bawei.common.core.domain.R;
import com.bawei.mall.user.domain.MallUserFootprint;
import com.bawei.mall.user.domain.UserList;
import com.bawei.mall.user.service.FootprintService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：张余庆
 * @Package：com.bawei.mall.user.contorller
 * @Project：mall_cloud
 * @name：FootprintContorller
 * @Date：2024/7/1 20:30
 */
@RestController
@RequestMapping("/readHistory")
public class MallFootprintContorller {

    @Autowired
    private FootprintService service;

    /**
     * 功能：查询用户足迹表
     */
    @GetMapping("/list")
    @ApiOperation("查询用户足迹表")
    public R<UserList> list(@RequestParam(value = "pageNum") Integer pageNum,
                            @RequestParam(value = "pageSize") Integer pageSize){
        UserList list = service.list(pageNum,pageSize);
        return R.ok(list);
    }

    /**
     * 功能：删除用户足迹
     * @param id
     * @return
     */
    @GetMapping("delFootprint/{id}")
    @ApiOperation("删除用户足迹")
    public R delFootprint(@PathVariable("id") Integer id){
        service.delFootprint(id);
        return R.ok();
    }

    /**
     * 功能：添加用户足迹
     * @param footprint
     * @return
     */
    @PostMapping("add")
    @ApiOperation("添加用户足迹")
    public R add(@RequestBody MallUserFootprint footprint){
        service.add(footprint);
        return R.ok();
    }
}
